package main

import (
	"flag"
	"fmt"

	"gitee.com/xgotool/backend-framework-template/config"
	"gitee.com/xgotool/backend-framework-template/router"
)

// 程序入口文件
func main() {
	path := ""
	listen := ""
	dsn := ""
	flag.StringVar(&path, "f", "", "指定配置文件位置")
	flag.StringVar(&listen, "l", "", "指定监听地址")
	flag.StringVar(&dsn, "d", "", "指定数据库连接串")
	flag.Parse()
	conf := config.GetDefault()
	if path != "" {
		conf.SetPath(path)
	}
	if listen != "" {
		conf.Listen = listen
	}
	if dsn != "" {
		conf.DSN = dsn
	}
	// 基础配置项信息
	go func() {
		config.GetConnect()
	}()
	// 路由配置项信息
	r := router.RouterExplode("")
	fmt.Println("运行成功，开始监听端口: ", conf.Listen)
	r.Run(conf.Listen)
}
